//-----------------------------------------------------------------------
// <copyright file="LoginPresenterTest.cs" company="Simnova LLC">
//     Copyright (c) Simnova LLC. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Simnova.Collaborate.Presenter.Test
{
    using System;
    using System.Text;
    using System.Collections.Generic;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Simnova.Collaborate.View;
    using Simnova.Collaborate.Presenter;

    /// <summary>
    /// Summary description for LoginPresenterTest
    /// </summary>
    [TestClass]
    public class LoginPresenterTest
    {
        public LoginPresenterTest()
        {
            // TODO: Add constructor logic here
        }
 
        [TestMethod]
        public void FailLogin()
        {
            MockLogin mockLogin = new MockLogin();
            mockLogin.EmailAddress = "fakeuser@somedomain.com";
            mockLogin.Password = "incorrectPassword";
            try
            {
                mockLogin.Login();
            }
            catch (Simnova.Collaborate.Presenter.LogOnPresenter.LogOnException e)
            {
                Assert.AreEqual(e.Message, "Login Failed");
            }
        }

        [TestMethod]
        public void PassLogin()
        {
            int userId;
            MockLogin mockLogin = new MockLogin();
            mockLogin.EmailAddress = "temp";
            mockLogin.Password = "temp";
            userId = mockLogin.Login();
            Assert.AreEqual(10, userId);
        }

        public class MockLogin : ILogOn
        {
            private LogOnPresenter loginPresenter;
            private string emailAddress;
            private string password;

            public MockLogin()
            {
                this.loginPresenter = new LogOnPresenter(this);
            }

            #region ILogin Members

            public string EmailAddress
            {
                get
                {
                    return this.emailAddress;
                }

                set
                {
                    this.emailAddress = value;
                }
            }

            public string Password
            {
                get
                {
                    return this.password;
                }

                set
                {
                    this.password = value;
                }
            }

            #endregion

            public int Login()
            {
                return this.loginPresenter.LogOn();
            }
        }
    }
}
